<html>

<head>
    <title> {{ context.title }} </title>
    {% include 'tab_scripts.html' %}
    {% include 'tab_styles.html' %}
</head>

<body>
    <div class="container-{{ context.rnd }}">
        <div class="tabs-{{ context.rnd }}">
            {% for title in context.meta %}
            <input type="radio" name="select" id="tab-{{ context.rnd }}-{{ loop.index }}" {{ 'checked' if loop.first }} onclick="switchTab{{ context.rnd }}(this)">
            <label for="tab-{{ context.rnd }}-{{ loop.index }}">{{ title }}</label>
            {% endfor %}
        </div>
        {% if context.legend_labels %}
        <div class="plot-legend-{{ context.rnd }}">
            {% for legend in context.legend_labels %}
                <div class="legend-bar-{{ context.rnd }}">
                    <div class="legend-color-{{ context.rnd }}" style="background-color: {{ legend.color }};"></div>
                    {% if loop.index0 == context.baseline %}
                    <div class="legend-label-{{ context.rnd }}"><strong>{{ legend.label }}</strong></div>
                    {% else %}
                    <div class="legend-label-{{ context.rnd }}">{{ legend.label }}</div>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
        {% endif %}
        <div class="contents-{{ context.rnd }}">
            {% if context.tabledata or context.comparison_stats%}
            <div class="plots-{{ context.rnd }}">
                <div class="stats-{{ context.rnd }}">
                    {% if context.tabledata%}
                    {% for title, table in context.tabledata.items() %}
                    <div class="tabledata-{{ context.rnd }}">
                        <h3>{{ title }}</h3>
                        <table>
                            {% for th, td in table.items() %}
                            <tr>
                                <th>{{ th }}</th><td>{{ td }}</td>
                            </tr>
                            {% endfor %}
                        </table>
                    </div>
                    {% endfor %}
                    {% endif %}

                    {% if context.comparison_stats %}
                    {% for title, table in context.comparison_stats.items() %}
                    <div class="tabledata-{{ context.rnd }}">
                        <h3>{{ title }}</h3>
                        <table>
                            <tr id="comp-label-{{ context.rnd }}">
                            <th></th>
                            {% for df_label in context.df_labels %}
                            <td style="color: {{ context.legend_labels[loop.index0].color }}">{{ df_label }}</td>
                            {% endfor %}
                            </tr>
                            {% for th, td in table.items() %}
                            <tr>
                                <th>{{ th }}</th>
                                {% for df_stat in td %}
                                <td>{{ df_stat }}</td>
                                {% endfor %}
                            </tr>
                            {% endfor %}
                        </table>
                    </div>
                    {% endfor %}
                    {% endif %}
                </div>
            </div>
            {% endif %}
            {% for fig in context.components[1] %}
            <div class="plots-{{ context.rnd }}">
                {% if context.how_to_guide[context.figs[loop.index - 1]] %}
                <div class="insight-container-{{ context.rnd }}">
                    <input type='checkbox' style='display: none' id="htgbt-{{ context.rnd }}-{{ loop.index0 }}" class="insight-check-{{ context.rnd }}">
                    <label class="htg-btn-{{ context.rnd }}" for="htgbt-{{ context.rnd }}-{{ loop.index0 }}"></label>
                    <div class="insight-panel-{{ context.rnd }}" style="padding:20px;">
                        {% for desc in context.how_to_guide[context.figs[loop.index - 1]] %}
                        <div class="htg-entry-{{ context.rnd }}">
                            <div class="htg-entry-conf-{{ context.rnd }}">{{ desc[0] }}</div>
                            <div class="htg-entry-desc-{{ context.rnd }}">{{ desc[1] }}</div>
                        </div>
                        {% endfor %}
                        <button class="htg-copy-btn-{{ context.rnd }}" onclick="copyParam(this)">Copy All Parameters</button>
                    </div>
                </div>
                {% endif %}
                {% if context.insights[context.figs[loop.index - 1]] %}
                <div class="insight-container-{{ context.rnd }}">
                    <input type='checkbox' style='display: none' id="ib-{{ context.rnd }}-{{ loop.index0 }}" class="insight-check-{{ context.rnd }}">
                    <label class="insight-btn-{{ context.rnd }}" for="ib-{{ context.rnd }}-{{ loop.index0 }}"></label>
                    <div class="insight-panel-{{ context.rnd }}">
                        <ul>
                            {% for insight in context.insights[context.figs[loop.index - 1]] %}
                            <li class="entry-{{ context.rnd }}">
                                {{ insight }}
                            </li>
                            {% endfor %}
                        </ul>
                    </div>
                </div>
                {% endif %}
                {{ fig }}
            </div>
            {% endfor %}
            {% if context.value_table %}
            <div class="plots-{{ context.rnd }}"  style="background: none;">
                <div class="insight-container-{{ context.rnd }}">
                    <input type='checkbox' style='display: none' id="htgbt-{{ context.rnd }}" class="insight-check-{{ context.rnd }}">
                    <label class="htg-btn-{{ context.rnd }}" for="htgbt-{{ context.rnd }}"></label>
                    <div class="insight-panel-{{ context.rnd }}" style="padding:20px;">
                        {% for desc in context.how_to_guide["Value Table"] %}
                        <div class="htg-entry-{{ context.rnd }}">
                            <div class="htg-entry-conf-{{ context.rnd }}">{{ desc[0] }}</div>
                            <div class="htg-entry-desc-{{ context.rnd }}">{{ desc[1] }}</div>
                        </div>
                        {% endfor %}
                        <button class="htg-copy-btn-{{ context.rnd }}" onclick="copyParam(this)">Copy All Parameters</button>
                    </div>
                </div>
                <table class="freq table table-hover table-striped">
                    <thead>
                        <tr>
                            <td>Value</td>
                            <td>Count</td>
                            <td>Frequency (%)</td>
                        </tr>
                    </thead>
                    <tbody>
                    {% for row in context.value_table %}
                        <tr class="{{ row['extra_class'] }}">
                            <td title="{{ row['label'] }}">{{ row['label'] }}</td>
                            <td>{{ row['count'] }}</td>
                            <td>
                                <div class="bar" style="width:{{ row['width_perc'] }}">
                                    {% if row['width'] > 0.20 %}
                                        {{ row['percentage'] }}
                                    {% else %}
                                        &nbsp;
                                    {% endif %}
                                </div>
                                {% if row['width'] <= 0.20 %}
                                    {{ row['percentage'] }}
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            {% endif %}
        </div>
    </div>
</body>